<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Python3入门机器学习经典算法与应用,">










<meta name="description" content="本文为慕课网《Python3入门机器学习经典算法与应用》的第一章、第二章，主要讲解：课程概述和机器学习基础本课程视频地址：https://coding.imooc.com/class/169.html本课程代码地址：https://gitee.com/aiolos123/machine-learning-classical-algorithm-with-python3讲师代码地址：https://">
<meta name="keywords" content="Python3入门机器学习经典算法与应用">
<meta property="og:type" content="article">
<meta property="og:title" content="【一】Python3入门机器学习经典算法与应用——课程概述和机器学习基础">
<meta property="og:url" content="https://aiolos123.gitee.io/blog/2019/12/12/machine-learning-classical-algorithm-1/index.html">
<meta property="og:site_name" content="Aiolos">
<meta property="og:description" content="本文为慕课网《Python3入门机器学习经典算法与应用》的第一章、第二章，主要讲解：课程概述和机器学习基础本课程视频地址：https://coding.imooc.com/class/169.html本课程代码地址：https://gitee.com/aiolos123/machine-learning-classical-algorithm-with-python3讲师代码地址：https://">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212122702435.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212123431821.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212123831015.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212125227241.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212125818834.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212125035356.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212130526875.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212131431321.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212142708950.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212140134456.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212140303518.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212142920753.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212144347102.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212150142602.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212150600899.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212172202058.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191212173418469.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213100016438.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213101942559.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213102233073.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213103808565.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213111150397.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213125413324.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213125441862.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213130238493.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213175204304.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213175349963.jpg">
<meta property="og:image" content="https://aiolos123.gitee.io/blog/images/20191213175608788.jpg">
<meta property="og:updated_time" content="2019-12-13T10:05:05.658Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="【一】Python3入门机器学习经典算法与应用——课程概述和机器学习基础">
<meta name="twitter:description" content="本文为慕课网《Python3入门机器学习经典算法与应用》的第一章、第二章，主要讲解：课程概述和机器学习基础本课程视频地址：https://coding.imooc.com/class/169.html本课程代码地址：https://gitee.com/aiolos123/machine-learning-classical-algorithm-with-python3讲师代码地址：https://">
<meta name="twitter:image" content="https://aiolos123.gitee.io/blog/images/20191212122702435.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://aiolos123.gitee.io/blog/2019/12/12/machine-learning-classical-algorithm-1/">





  <title>【一】Python3入门机器学习经典算法与应用——课程概述和机器学习基础 | Aiolos</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Aiolos</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">记录我的成长点滴</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://aiolos123.gitee.io/blog/blog/2019/12/12/machine-learning-classical-algorithm-1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="aiolos">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Aiolos">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">【一】Python3入门机器学习经典算法与应用——课程概述和机器学习基础</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-12-12T05:59:13+08:00">
                2019-12-12
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/机器学习/" itemprop="url" rel="index">
                    <span itemprop="name">机器学习</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>本文为慕课网《Python3入门机器学习经典算法与应用》的第一章、第二章，主要讲解：课程概述和机器学习基础<br>本课程视频地址：<a href="https://coding.imooc.com/class/169.html" target="_blank" rel="noopener">https://coding.imooc.com/class/169.html</a><br>本课程代码地址：<a href="https://gitee.com/aiolos123/machine-learning-classical-algorithm-with-python3" target="_blank" rel="noopener">https://gitee.com/aiolos123/machine-learning-classical-algorithm-with-python3</a><br>讲师代码地址：<a href="https://github.com/liuyubobobo/Play-with-Machine-Learning-Algorithms" target="_blank" rel="noopener">https://github.com/liuyubobobo/Play-with-Machine-Learning-Algorithms</a></p>
<a id="more"></a>

<h2 id="课程介绍"><a href="#课程介绍" class="headerlink" title="课程介绍"></a>课程介绍</h2><h3 id="什么是机器学习"><a href="#什么是机器学习" class="headerlink" title="什么是机器学习"></a>什么是机器学习</h3><blockquote>
<p>喂给机器数据、让机器在大量数据中寻找输入与蔬菜的关系，建立模型f(x)，并应用这个模型进行预测</p>
</blockquote>
<blockquote>
<p>程序算法：让机器、去执行<br>机器学习：让机器、去学习</p>
</blockquote>
<ol>
<li><p>最早的机器学习应用：垃圾邮件分辨</p>
</li>
<li><p>传统的程序算法解决”垃圾邮件分辨”问题的思路及其缺点：<br><img src="/blog/images/20191212122702435.jpg" alt="传统的程序算法解决&quot;垃圾邮件分辨&quot;问题的思路"></p>
</li>
</ol>
<p>图像识别等很多实际问题中也存在上述两个缺点！</p>
<ol start="3">
<li><p>人类怎么去学习————根据知识、经验学习<br><img src="/blog/images/20191212123431821.jpg" alt="人类怎么去学习"></p>
</li>
<li><p>机器怎么去学习(什么是机器学习)： 与人类相似<br><img src="/blog/images/20191212123831015.jpg" alt="人类怎么去学习"></p>
</li>
<li><p>机器学习的应用：垃圾邮件分辨、图像识别、人脸识别、数字识别、风险预估、搜索引擎关键字推荐、商品推荐、语音识别、量化交易、市场分析</p>
</li>
<li><p>未来更多领域将应用机器学习：无人驾驶、安全领域、医疗领域、金融领域、自然语言处理、专业领域</p>
</li>
</ol>
<h3 id="课程主要内容"><a href="#课程主要内容" class="headerlink" title="课程主要内容"></a>课程主要内容</h3><ol>
<li><p>本课程的主要内容是讲解机器学习的相关算法<br><img src="/blog/images/20191212125227241.jpg" alt="课程主要内容"><br><img src="/blog/images/20191212125818834.jpg" alt="课程主要内容">  </p>
</li>
<li><p>人工智能、机器学习、深度学习的关系<br><img src="/blog/images/20191212125035356.jpg" alt="关系">  </p>
</li>
<li><p>神经网络也是机器学习算法中的一种，并且是深度学习的基础</p>
</li>
<li><p>课程目标</p>
<blockquote>
<p>算法原理的学习；部分算法底层的编写；scikit-learn机器学习库的使用</p>
</blockquote>
</li>
</ol>
<h3 id="课程使用的技术栈"><a href="#课程使用的技术栈" class="headerlink" title="课程使用的技术栈"></a>课程使用的技术栈</h3><ol>
<li>课程环境<blockquote>
<p>Python3、Scikit-learn、numpy、matplotlib、Jupyter Notebook、</p>
</blockquote>
</li>
</ol>
<p><img src="/blog/images/20191212130526875.jpg" alt="课程环境">  </p>
<ol start="2">
<li><p>本课程学习条件</p>
<blockquote>
<p>Python3基础、高中数学水平</p>
</blockquote>
</li>
<li><p>本课程所使用的数据集</p>
<blockquote>
<p>框架Scikit-learn内置的数据集或通过Scikit-learn可以直接下载的数据集</p>
</blockquote>
</li>
<li><p>本课程不涵盖的内容<br><img src="/blog/images/20191212131431321.jpg" alt="本课程不涵盖的内容">  </p>
</li>
</ol>
<h2 id="机器学习基础"><a href="#机器学习基础" class="headerlink" title="机器学习基础"></a>机器学习基础</h2><blockquote>
<p>矩阵：由m×n个数组成的一个m行n列的矩形阵列，并写在方括号中间。一般用大写字母表示矩阵<br>向量：向量是特殊的矩阵。 向量是只有一列或者一行的矩阵，<strong>一般说到向量都是指只有一列的向量，即列向量</strong>。一般用小写字母表示向量</p>
</blockquote>
<p><img src="/blog/images/20191212142708950.jpg" alt="矩阵与向量"></p>
<h3 id="机器学习世界的数据相关概念"><a href="#机器学习世界的数据相关概念" class="headerlink" title="机器学习世界的数据相关概念"></a>机器学习世界的数据相关概念</h3><ol>
<li>以鸢尾花为例，说明机器学习世界中的数据相关概念<blockquote>
<p>著名的鸢尾花数据 <a href="https://en.wikipedia.org/wiki/lris_flower_data_set" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/lris_flower_data_set</a></p>
</blockquote>
</li>
</ol>
<p>三种鸢尾花如下图：<br><img src="/blog/images/20191212140134456.jpg" alt="机器学习世界的数据"><br>关于鸢尾花的数据(每一组数据都是如下5种信息)：<br><img src="/blog/images/20191212140303518.jpg" alt="机器学习世界的数据">  </p>
<ol start="2">
<li>机器学习世界中的数据相关概念<blockquote>
<p>数据集(data set)： 参与机器学习的数据整体叫数据集——通常都可以将数据集写成一个表格<br>样本(sample)：每一行数据称为一个样本。下图中每一行都表示一朵花的样本数据<br>特征(feature)：下图中除最后一列外，每一列表述样本的一个特征——等同于样本的一个属性<br>标记(label): 最后一列称为标记。标记是机器学习最终想得到的结论，也是机器学习的主要任务。<br>(实际上为计算机处理方便，希望最终的数据处理结果都数字化，所以将鸢尾花的三类se、ve、vi分别表示为0、1、2)</p>
</blockquote>
</li>
</ol>
<blockquote>
<p>X(特征矩阵)：由样本的特征构成的矩阵<br>y(标记向量)：由标记构成的向量</p>
</blockquote>
<p><img src="/blog/images/20191212142920753.jpg" alt="机器学习世界中的数据相关概念">  </p>
<blockquote>
<p>特征向量：由每一行样本的特征构成的向量，即第i个样本行</p>
</blockquote>
<p><img src="/blog/images/20191212144347102.jpg" alt="特征向量">  </p>
<blockquote>
<p>特性空间(featrue space)： 由样本的N个特征就可以构成一个N维的特征空间，每一个样本都会在这个特征空间的坐标系中表示为一个点。<br>假设我们有三个特征，就可以在三维空间中表示它，同理如果有1000种特征，就可以在1000维的空间中表示它，而这个绘制样本的空间我们称它为特征空间(feature space)。</p>
</blockquote>
<p>为了可视化特征方便，我们只抽取出特征中的前两个特征，其中萼片的长度作为横轴，萼片的宽度作为纵轴。绘制下图。<br><img src="/blog/images/20191212150142602.jpg" alt="特性空间">  </p>
<p>注意：<br><strong>a. 通过可视化绘制样本点后，我们可以比较轻易的绘制出一根直线，红色样本在直线的一边而蓝色样本在直线的另一边。</strong><br><strong>b. 机器学习的算法如果在低维空间中成立，那么推广到高维空间也同样成立</strong></p>
<blockquote>
<p>样本特征的含义：可能有具体的语义如鸢尾花，也可能很抽象，毫无语义如图像识别</p>
</blockquote>
<p><img src="/blog/images/20191212150600899.jpg" alt="样本特征的含义">  </p>
<p><strong>样本特征是决定机器学习算法最终的可靠性、稳定性、有效性的决定因素！</strong><br>因此有分析特征的专业方向：特征工程；而深度学习则是机器自动进行特征工程分析</p>
<h3 id="机器学习可以解决的两类基本问题"><a href="#机器学习可以解决的两类基本问题" class="headerlink" title="机器学习可以解决的两类基本问题"></a>机器学习可以解决的两类基本问题</h3><ol>
<li>分类问题： 最终得到的标签为离散型结果(一种或几种类别)。具体包括三类：二分类问题(即yes-or-no类型问题)、多分类问题(如数字识别、图像识别、无人驾驶等很多复杂问题都<strong>可以</strong>转化为多分类任务问题)和多标签分类问题</li>
</ol>
<blockquote>
<p>有一些算法只支持完成二分类问题<br>多分类问题可以转换为二分类问题<br>有一些算法天然可以完成多分类问题</p>
</blockquote>
<p>多标签分类问题(属于前沿研究课题)： 同一个样本数据分到多个标签下<br><img src="/blog/images/20191212172202058.jpg" alt="多标签分类"></p>
<ol start="2">
<li>回归问题： 最终得到的标签为连续性结果(一个连续数字的具体数值),而非一个类别。具体包括：</li>
</ol>
<blockquote>
<p>有一些算法只能解决回归问题<br>有一些算法只能解决分类问题<br>有一些算法既能解决回归问题，又能解决分类问题</p>
</blockquote>
<p><strong>在一些情况下，回归问题可以简化为分类问题</strong>，如无人驾驶问题</p>
<ol start="3">
<li>再看什么是机器学习？<br>如下图所示(机器学习中的模型就是一个函数f(x) )：</li>
</ol>
<blockquote>
<p>将大量的学习资料喂给机器学习算法后,机器学习算法将训练出一个模型，将输入样例输入到模型中得到输出结果，如果模型是输出一个具体的类别，那么我们解决的就是一个分类问题，如果模型输出的是一个具体的数值，那么我们解决的就是一个回归问题。</p>
</blockquote>
<p><img src="/blog/images/20191212173418469.jpg" alt="多标签分类"></p>
<h3 id="机器学习算法的四大分类"><a href="#机器学习算法的四大分类" class="headerlink" title="机器学习算法的四大分类"></a>机器学习算法的四大分类</h3><blockquote>
<p>监督学习和半监督学习是所有机器学习算法的基础</p>
</blockquote>
<h4 id="监督学习"><a href="#监督学习" class="headerlink" title="监督学习"></a>监督学习</h4><ol>
<li>监督学习: 喂给机器的训练数据集拥有“标记”或者“答案”。 </li>
</ol>
<p><img src="/blog/images/20191213100016438.jpg" alt="监督学习"></p>
<ol start="2">
<li><p>监督的含义：人类已经为数据集标注了正确的标记或答案，从而监督机器能否正确的得到结果</p>
</li>
<li><p>运用监督学习的场景举例：</p>
<blockquote>
<p>图像已经拥有了标定信息<br>银行已经积累了一定的客户信息和他们信用卡的实用信息<br>医院已经积累了一定的病人信息和他们最终确诊是否患病的情况<br>市场积累了房屋的基本信息和最终成交的金额<br>……等等</p>
</blockquote>
</li>
<li><p>监督学习主要处理两大类问题：分类问题和回归问题<br>(因为本课程主要处理的问题是分类问题和回归问题，所以本课程主要讲解监督学习算法)</p>
</li>
<li><p>此课程中学习的大部分算法属于监督学习算法，只学一个非监督学习算法</p>
<blockquote>
<p>K近邻<br>线性回归和多项式回归<br>逻辑回归<br>SVM<br>决策树和随机森林</p>
</blockquote>
</li>
</ol>
<h4 id="非监督学习："><a href="#非监督学习：" class="headerlink" title="非监督学习："></a>非监督学习：</h4><ol>
<li><p>非监督学习： 喂给机器训练数据没有任何“标记”或者“答案”<br><img src="/blog/images/20191213101942559.jpg" alt="非监督学习"></p>
</li>
<li><p>非监督学习的作用一：数据分类————即聚类分析；</p>
<blockquote>
<p>聚类分析: 对没有”标记”的数据进行分类</p>
</blockquote>
</li>
</ol>
<p><img src="/blog/images/20191213102233073.jpg" alt="非监督学习的作用"></p>
<ol start="3">
<li><p>非监督学习的作用二：数据降维</p>
<blockquote>
<p>数据降维：对数据进行降维处理。<br>数据降维主要包括两部分：特征提取(提取数据中的有用特征，如信用卡的信用等级与胖瘦有无关系)、特征压缩(在尽量少损失数据信息的前提下，将高维的特征向量压缩为低维的特征向量，提高机器学习算法的运行效率,又不影响预测的准确率，同时方便在二维、三维空间的可视化展示)<br>数据降维的主要手段是PCA</p>
</blockquote>
</li>
<li><p>非监督学习的作用三：异常检测，用于剔除这些样本<br><img src="/blog/images/20191213103808565.jpg" alt="非监督学习的作用"></p>
</li>
</ol>
<h4 id="半监督学习"><a href="#半监督学习" class="headerlink" title="半监督学习"></a>半监督学习</h4><ol>
<li>半监督学习： 一部分数据有“标记”或者“答案”，另一部分没有</li>
<li>现实世界中这种情况更常见，由于各种原因产生了标记缺失。而有完整标记的数据则是最理想的情况。</li>
<li>半监督学习的处理流程：通常都是先使用非监督学习手段对数据做处理(使数据变成监督学习模式的数据集)、之后再使用监督学习手段做模型的训练和预测</li>
</ol>
<h4 id="增强学习"><a href="#增强学习" class="headerlink" title="增强学习"></a>增强学习</h4><ol>
<li><p>增强学习： 机器学习算法agent会根据周围环境的情况，采取行动，根据采取行动的结果反馈，不断改进算法agent的行动方式。<br><img src="/blog/images/20191213111150397.jpg" alt="增强学习"></p>
</li>
<li><p>增强学习的应用：AlphaGo、机器人、无人驾驶，属于最前沿的研究领域</p>
</li>
</ol>
<h3 id="机器学习算法其他分类方式"><a href="#机器学习算法其他分类方式" class="headerlink" title="机器学习算法其他分类方式"></a>机器学习算法其他分类方式</h3><p>本小节从另外两个维度再对机器学习算法进行分类</p>
<h4 id="在线学习和离线学习-也叫批量学习"><a href="#在线学习和离线学习-也叫批量学习" class="headerlink" title="在线学习和离线学习(也叫批量学习)"></a>在线学习和离线学习(也叫批量学习)</h4><ol>
<li>离线学习(也叫批量学习)： 通过机器学习算法训练出来的模型，在生成环境的使用过程中模型不再改进、优化————即模型不随样例数据的变化而改进<blockquote>
<p>本课程之前介绍的机器学习算法在没有特殊说明的情况下，都可以使用批量学习的方式进行机器学习</p>
</blockquote>
</li>
</ol>
<p><img src="/blog/images/20191213125413324.jpg" alt="离线学习"><br>离线学习优点：简单，训练出来的模型直接可以<br>离线学习问题：无法适应环境的变化————定时重新进行离线学习、训练模型。但每次重新进行离线学习的运算量巨大、并且耗时</p>
<ol start="2">
<li>在线学习：机器学习算法将输入的样例和正确结果作为训练数据，迭代训练模型，在生成环境的使用过程中模型不断训练、改进————即模型随着样例数据的变化而不断训练、改进<br><img src="/blog/images/20191213125441862.jpg" alt="在线学习"></li>
</ol>
<p>在线学习优点：及时反映新的环境变化；也适用于数据量巨大、完全无法离线学习的环境<br>在线学习问题：新的数据带来不好的变化————需要加强对数据进行监控，及时检测异常数据。</p>
<h4 id="参数学习和非参数学习"><a href="#参数学习和非参数学习" class="headerlink" title="参数学习和非参数学习"></a>参数学习和非参数学习</h4><ol>
<li>参数学习：假设出f(x)的表达式，机器学习主要是来确定各参数的值<br><img src="/blog/images/20191213130238493.jpg" alt="参数学习"></li>
</ol>
<p>参数学习的特点：喂给机器学习算法的大量数据主要是用于学到参数，一旦参数确定了，就不再需要原有的数据集了</p>
<ol start="2">
<li>非参数学习： 不对模型进行过多假设。非参数不等于没参数！</li>
</ol>
<h3 id="和机器学习相关的哲学思考"><a href="#和机器学习相关的哲学思考" class="headerlink" title="和机器学习相关的哲学思考"></a>和机器学习相关的哲学思考</h3><p>经典算法：给予的答案也是准确的<br>机器学习算法：给予的答案也是不准确的，是有概率的</p>
<ol>
<li>数据即算法？————随着训练数据的规模越来越多，预测结果的准确率也会越来越高<blockquote>
<p>数据确实非常重要；目前的机器学习是数据驱动(高度依赖数据的质量);</p>
</blockquote>
</li>
</ol>
<p><img src="/blog/images/20191213175204304.jpg" alt="数据即算法"></p>
<ol start="2">
<li>算法为王？ ———— AlphaGo Zero只有算法、无需输入数据</li>
</ol>
<p><img src="/blog/images/20191213175349963.jpg" alt="算法为王"></p>
<ol start="3">
<li>如何选择机器学习算法？<blockquote>
<p>奥卡姆的剃刀：简单的就是好的<br>在机器学习领域，到底什么叫”简单”?<br>具体到某个特定问题，有些算法可能更好。但没有一种算法、绝对比另一种算法更好。<br>脱离具体问题，谈哪个算法好是没有意义的。<br>在面对一个具体问题时，尝试多种算法进行对比试验，是必要的！</p>
</blockquote>
</li>
</ol>
<p><img src="/blog/images/20191213175608788.jpg" alt="如何选择机器学习算法"></p>
<ol start="4">
<li>面对不确定的世界，怎么看待使用机器学习进行预测的结果？————巧合 or 必然</li>
</ol>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/Python3入门机器学习经典算法与应用/" rel="tag"># Python3入门机器学习经典算法与应用</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2019/12/10/spring-cloud-weather-9/" rel="next" title="【九】从天气项目看Spring Cloud微服务治理——微服务的自动扩展介绍">
                <i class="fa fa-chevron-left"></i> 【九】从天气项目看Spring Cloud微服务治理——微服务的自动扩展介绍
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2019/12/13/machine-learning-classical-algorithm-2/" rel="prev" title="【二】Python3入门机器学习经典算法与应用——Jupyter Notebook, numpy和matplotlib基础">
                【二】Python3入门机器学习经典算法与应用——Jupyter Notebook, numpy和matplotlib基础 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">aiolos</p>
              <p class="site-description motion-element" itemprop="description">Java Spring Hadoop 机器学习</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">126</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/blog/tags/index.html">
                  <span class="site-state-item-count">33</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#课程介绍"><span class="nav-number">1.</span> <span class="nav-text">课程介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#什么是机器学习"><span class="nav-number">1.1.</span> <span class="nav-text">什么是机器学习</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#课程主要内容"><span class="nav-number">1.2.</span> <span class="nav-text">课程主要内容</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#课程使用的技术栈"><span class="nav-number">1.3.</span> <span class="nav-text">课程使用的技术栈</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#机器学习基础"><span class="nav-number">2.</span> <span class="nav-text">机器学习基础</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#机器学习世界的数据相关概念"><span class="nav-number">2.1.</span> <span class="nav-text">机器学习世界的数据相关概念</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#机器学习可以解决的两类基本问题"><span class="nav-number">2.2.</span> <span class="nav-text">机器学习可以解决的两类基本问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#机器学习算法的四大分类"><span class="nav-number">2.3.</span> <span class="nav-text">机器学习算法的四大分类</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#监督学习"><span class="nav-number">2.3.1.</span> <span class="nav-text">监督学习</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#非监督学习："><span class="nav-number">2.3.2.</span> <span class="nav-text">非监督学习：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#半监督学习"><span class="nav-number">2.3.3.</span> <span class="nav-text">半监督学习</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#增强学习"><span class="nav-number">2.3.4.</span> <span class="nav-text">增强学习</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#机器学习算法其他分类方式"><span class="nav-number">2.4.</span> <span class="nav-text">机器学习算法其他分类方式</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#在线学习和离线学习-也叫批量学习"><span class="nav-number">2.4.1.</span> <span class="nav-text">在线学习和离线学习(也叫批量学习)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#参数学习和非参数学习"><span class="nav-number">2.4.2.</span> <span class="nav-text">参数学习和非参数学习</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#和机器学习相关的哲学思考"><span class="nav-number">2.5.</span> <span class="nav-text">和机器学习相关的哲学思考</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">aiolos</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/blog/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

</body>
</html>
